<template>
  <div>
       <van-nav-bar
         left-arrow
        class="app-nav-bar"
        title="返单"
        @click-left="$router.back()"
      />
       <van-form @submit="onSubmit">
        <van-field
                v-model="handlerContent"
                right-icon="arrow"
                label="处理人"
                placeholder="请选择处理人"
                @click="handlerListShare=true"
            />
            <van-action-sheet 
                v-model="handlerListShare"
                title="请选择"
                :actions="userList" 
                @select="onSelect" 
            />
            <div style="margin:16px">
                <van-button round block type="info" native-type="submit">提交</van-button>
            </div>
        </van-form>
  </div>
</template>

<script>
export default {
    name:'transferOrder',
    data(){
        return{
            userId: null,
            userList:[],
            handlerContent:'',
            handlerListShare:false
        }
    },
    methods:{
        async onSubmit(){
            var {data:res} = await this.request({
                url:this.$location.transferOrder,
                method:'get',
                params:{
                    districtId:this.$route.params.districtId,
                    id:this.$route.params.id,
                    userId:this.userId
                }
            })
            console.log(res);
             if(res.status==200){
                this.$toast.success(res.msg)
                 this.$router.push('/event');
            }else{
                this.$toast.fail(res.msg)
                 this.$router.push('/event');
            }
        },
        async getUserListAll(){
            const {data:res} =await this.request({url:this.$location.getUserListAll});
            res.data.forEach(item=>{
                this.userList.push({
                    id:item.id,
                    name:item.username
                })
            })
        },
         onSelect(item){
            console.log(item)
            this.handlerContent=item.name;
            this.userId=item.id
            this.handlerListShare = false;
        },
    },
    created(){
        this.getUserListAll();
        // console.log(this.$route.params.id)
    }
}
</script>

<style>

</style>